package com.fengxun.software_cup.controller;
// 团   队: 风讯网络
// 后   端: Dopa
// 开发时间: 2021/6/14 13:23

import com.fengxun.software_cup.pojo.CommonResult;
import com.fengxun.software_cup.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;


@Slf4j
@RestController
@CrossOrigin
public class UserController {
    @Resource
    UserService service;
    @Value("${pythonPath}")
    String pythonPath;
    @Value("${filePath}")
    String filePath;

    /**
     *接收并处理文件
     * @param files 接收的文档
     * @return 响应类
     */
    @PostMapping("/putFile")
    public CommonResult<Object> putFile(MultipartFile[] files) {
        return service.putFiles(files);
    }


    /**
     * 生成报告，前端下载
     * @param response HttpServletResponse
     */
    @GetMapping("/getWord")
    public void generateReport(HttpServletResponse response) {
        service.generateReport(response);
    }
}
